package cn.tedu.sp02.service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.springframework.stereotype.Service;

import cn.tedu.sp01.pojo.Item;
import cn.tedu.sp01.service.ItemService;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class ItemServiceImpl implements ItemService {

    @Override
    public List<Item> getItems(String orderId) {
        log.info("获取订单的商品列表,orderId="+orderId);
        //Demo数据
        return Arrays.asList(new Item[]{
                new Item(1, "商品1", 1),
                new Item(2, "商品2", 5),
                new Item(3, "商品3", 2),
                new Item(4, "商品4", 4),
                new Item(5, "商品5", 1),
        });
    }

    @Override
    public void decreaseNumber(List<Item> items) {
        for (Item item : items) {
            log.info("减少库存 - " + item);
        }
    }
}
